package cn.itcast.hotel.lister;

import cn.itcast.hotel.constants.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class HotelListener {
    @Autowired
    IHotelService hotelService;
    @RabbitListener(queues = MqConstants.HOTEL_INSERT_KEY)
    public void listenInsertMsg(Long hotelId){
        log.info("接收到 更新酒店消息通知 酒店id：{}",hotelId);
        hotelService.insert(hotelId);
    }
    @RabbitListener(queues = MqConstants.HOTEL_DELETE_KEY)
    public void listenDeleteMsg(Long hotelId){
        log.info("接收到 删除酒店消息通知 酒店id：{}",hotelId);
        hotelService.delete(hotelId);
    }
}
